<template> 
    <el-dialog
      v-model="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
    <template #header>
        <div class="custom-header">用户协议</div>
    </template>
    <span>This is a message</span>
    <template #footer>
    <span class="dialog-footer">
        <el-button @click="dialogVisible = false">确认</el-button>
        <el-button type="primary" @click="dialogVisible = false">
        取消
        </el-button>
    </span>
    </template>
</el-dialog>
</template>
  
  <script lang="ts" setup>
  import { ref } from 'vue'
  import { ElMessageBox } from 'element-plus'
  
  const dialogVisible = ref(false)
  
  const handleClose = (done: () => void) => {
    ElMessageBox.confirm('Are you sure to close this dialog?')
      .then(() => {
        done()
      })
      .catch(() => {
        // catch error
      })
  }
  </script>
  <style scoped>
  .dialog-footer button:first-child {
    margin-right: 10px;
  }
  </style>
  